Repository navigation
Check the file version of spec JSON files - #1498
Merged
Merged
Conversation
Specification Appendix A.6.1 (hed-specification hed-standard#731): a validator must not apply a reserved_tags.json or character_sets.json whose file version major number it does not support. Fixes hed-standard#1489. - reserved_tags.json refreshed verbatim from hed-specification main; it gains specificationVersion and fileVersion. - New hed/validator/util/spec_files.py: check_file_version raises HedFileError INVALID_FILE_FORMAT when the version key is missing, is not major.minor.patch, or its major number is not 1. - ReservedChecker reads its file through the new load_reserved_file; CharacterSets checks the version before reading the sets. - Tests for accepted and refused versions of both files; CHANGELOG.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The version check accepts a trailing newline, allowing both loaders to apply files with malformed versions instead of raising HedFileError.
1 open issue
What changed in this PR
Adds file-version checks to the specification data loaders, addressing #1489 and the compatibility requirement in Appendix A.6.1.
Changes:
- Adds a shared check for missing, malformed, or unsupported file versions.
- Integrates the check into both loaders and refreshes reserved-tag version metadata.
- Adds version acceptance and rejection tests and documents the behavior.
| File | Description |
|---|---|
tests/validator/test_spec_files.py |
Tests shared version validation and malformed inputs. |
tests/validator/test_reserved_checker.py |
Tests reserved-tag metadata and loader version checks. |
tests/validator/test_character_sets.py |
Tests character-set version compatibility. |
hed/validator/util/spec_files.py |
Implements the shared file-version check. |
hed/validator/util/character_sets.py |
Checks file compatibility before loading character sets. |
hed/validator/reserved_checker.py |
Adds a version-checked reserved-tag loader. |
hed/validator/data/reserved_tags.json |
Adds specification and file version metadata. |
CHANGELOG.md |
Documents the metadata and compatibility checks. |
Review effort: Balanced
Address the Copilot review of PR hed-standard#1498: re.match with $ accepted "1.0.0\n", and \d accepted non-ASCII digits such as U+0661. Use fullmatch with [0-9], and test both strings as malformed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Specification Appendix A.6.1 (hed-specification #731): a validator must not apply a reserved_tags.json or character_sets.json whose file version major number it does not support. Fixes #1489.